﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var baotypeData = Jxstar.findComboData('baotype');
	var auditData = Jxstar.findComboData('audit');
	var checkdeptData = Jxstar.findComboData('checkdept');
	var projectjdData = Jxstar.findComboData('projectjd');
	var moneytypeData = Jxstar.findComboData('moneytype');
	var plantype2Data = Jxstar.findComboData('plantype2');
	var resulttypeData = Jxstar.findComboData('resulttype');
	var planstatus2Data = Jxstar.findComboData('planstatus2');
	var yesnoData = Jxstar.findComboData('yesno');
	var planyearData = Jxstar.findComboData('planyear');
	var planstatusData = Jxstar.findComboData('planstatus');

	var cols = [
	{col:{header:'计划包属性', width:28, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: baotypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: baotypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < baotypeData.length; i++) {
				if (baotypeData[i][0] == value)
					return baotypeData[i][1];
			}
		}}, field:{name:'money_plan__bao_type',type:'string'}},
	{col:{header:'记录状态', width:72, sortable:true, hidden:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: auditData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: auditData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < auditData.length; i++) {
				if (auditData[i][0] == value)
					return auditData[i][1];
			}
		}}, field:{name:'money_plan__auditing',type:'string'}},
	{col:{header:'项目名称', width:146, sortable:true}, field:{name:'money_plan__plan_name',type:'string'}},
	{col:{header:'建设内容及方案', width:263, sortable:true, hidden:true}, field:{name:'money_plan__plan_desc',type:'string'}},
	{col:{header:'*预计总投资(万元)', width:138, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__plan_money',type:'float'}},
	{col:{header:'*下达预计总投资(万元)', width:155, sortable:true, align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__check_money2',type:'float'}},
	{col:{header:'*本年度计划投资(万元)', width:166, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__year_money',type:'float'}},
	{col:{header:'*本年度下达计划投资(万元)', width:176, sortable:true, align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__year_money2',type:'float'}},
	{col:{header:'*项目审批权限', width:100, sortable:true, align:'center',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: checkdeptData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false, allowBlank:false,
			value: checkdeptData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < checkdeptData.length; i++) {
				if (checkdeptData[i][0] == value)
					return checkdeptData[i][1];
			}
		}}, field:{name:'money_plan__check_right2',type:'string'}},
	{col:{header:'国家局项目编号', width:115, sortable:true, editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.TextField({
			maxLength:20
		})}, field:{name:'money_plan__plan_code2',type:'string'}},
	{col:{header:'年度项目实施内容', width:136, sortable:true, editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.TextField({
			maxLength:200
		})}, field:{name:'money_plan__year_content2',type:'string'}},
	{col:{header:'当前形象进度', width:100, sortable:true, align:'center',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: projectjdData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: projectjdData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < projectjdData.length; i++) {
				if (projectjdData[i][0] == value)
					return projectjdData[i][1];
			}
		}}, field:{name:'money_plan__project_process',type:'string'}},
	{col:{header:'上年实际完成投资(万元)', width:119, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__money_pay1',type:'float'}},
	{col:{header:'累计完成投资(万元)', width:100, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__sun_money',type:'float'}},
	{col:{header:'项目类别', width:87, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: moneytypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: moneytypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < moneytypeData.length; i++) {
				if (moneytypeData[i][0] == value)
					return moneytypeData[i][1];
			}
		}}, field:{name:'money_plan__money_type',type:'string'}},
	{col:{header:'国家局项目类别', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: plantype2Data
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: plantype2Data[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < plantype2Data.length; i++) {
				if (plantype2Data[i][0] == value)
					return plantype2Data[i][1];
			}
		}}, field:{name:'money_plan__money_type2',type:'string'}},
	{col:{header:'提交备案时间', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__up_sdate',type:'date'}},
	{col:{header:'备案下达时间', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__up_edate',type:'date'}},
	{col:{header:'备案结果', width:78, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: resulttypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: resulttypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < resulttypeData.length; i++) {
				if (resulttypeData[i][0] == value)
					return resulttypeData[i][1];
			}
		}}, field:{name:'money_plan__up_result',type:'string'}},
	{col:{header:'项目状态', width:78, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planstatus2Data
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planstatus2Data[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planstatus2Data.length; i++) {
				if (planstatus2Data[i][0] == value)
					return planstatus2Data[i][1];
			}
		}}, field:{name:'money_plan__plan_status2',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_id',type:'string'}},
	{col:{header:'申报部门ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__dept_id',type:'string'}},
	{col:{header:'立项批复文号', width:100, sortable:true}, field:{name:'money_plan__project_fileno',type:'string'}},
	{col:{header:'立项批复金额(万元)', width:100, sortable:true, hidden:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__project_money',type:'float'}},
	{col:{header:'需报国家局', width:100, sortable:true, hidden:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: yesnoData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: yesnoData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < yesnoData.length; i++) {
				if (yesnoData[i][0] == value)
					return yesnoData[i][1];
			}
		}}, field:{name:'money_plan__up_comp',type:'string'}},
	{col:{header:'是否结转', width:64, sortable:true, hidden:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: yesnoData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: yesnoData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < yesnoData.length; i++) {
				if (yesnoData[i][0] == value)
					return yesnoData[i][1];
			}
		}}, field:{name:'money_plan__is_turn',type:'string'}},
	{col:{header:'预算年度', width:64, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planyearData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planyearData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planyearData.length; i++) {
				if (planyearData[i][0] == value)
					return planyearData[i][1];
			}
		}}, field:{name:'money_plan__plan_year',type:'string'}},
	{col:{header:'申报部门', width:100, sortable:true}, field:{name:'money_plan__dept_name',type:'string'}},
	{col:{header:'计划编号', width:107, sortable:true}, field:{name:'money_plan__plan_code',type:'string'}},
	{col:{header:'计划状态', width:83, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planstatusData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planstatusData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planstatusData.length; i++) {
				if (planstatusData[i][0] == value)
					return planstatusData[i][1];
			}
		}}, field:{name:'money_plan__plan_status',type:'string'}},
	{col:{header:'开工日期', width:100, sortable:true, hidden:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_sdate',type:'date'}},
	{col:{header:'竣工日期', width:100, sortable:true, hidden:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_edate',type:'date'}},
	{col:{header:'项目id', width:100, sortable:true, hidden:true}, field:{name:'money_plan__project_id',type:'string'}},
	{col:{header:'立项批复日期', width:100, sortable:true, hidden:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_checkdate',type:'date'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '1',
		isshow: '1',
		funid: 'money_memo_do'
	};
	
	//定义包标志列	cols[0].col.header = '';	cols[0].col.width = 28;	cols[0].col.renderer = function(val, meta, rec) {		var html = '';		var parentId = rec.get('money_plan__plan_id');		var baotype = rec.get('money_plan__bao_type');		var isturn = rec.get('money_plan__is_turn');		var imgname = 'folder' + baotype + '.gif';		if (baotype == '1' || baotype == '2') {			html = '<img src="resources/images/exp/'+ imgname +'" style="cursor:pointer;" title="点击查看子计划" '+				   'onClick="JxPm.showSubPlan(\''+ parentId +'\', \'money_bao_sub\', \''+ isturn +'\', \'money_memo_do\');"></img>';		}		return html;	};		config.initpage = function(gridNode) {		var event = gridNode.event;		//备案下达时检查数据的完整性，必填项必须填写		event.on('beforecustom', function(ge, eventCode) {			if (eventCode != 'memodo') return true;			var records = ge.grid.getSelectionModel().getSelections();			var cm = ge.grid.getColumnModel();			var store = ge.grid.getStore();			for (var i = 0, n = records.length; i < n; i++) {				var record = records[i];				var fields = record.fields.keys;				for (var j = 0; j < fields.length; j++) {					var name = fields[j];					var value = record.data[name];					if (value == null) value = '';					var colIndex = cm.findColumnIndex(name);					var rowIndex = store.indexOfId(record.id);					var editor = cm.getCellEditor(colIndex, rowIndex);					//隐藏字段为空					if (editor == null) continue;					var field = editor.field;					if (field != null && !field.validateValue(value)) {						JxHint.alert(jx.event.datavalid);	//请确保输入的数据正确完整。						ge.grid.startEditing(rowIndex, colIndex);						return false;					}				}			}			return true;		});	};
		
	return new Jxstar.GridNode(config);
}